"""
该文件用于 导航栏页面
"""
import uiautomation as auto
from page.base_page import BasePage
from utils.utils_log import loggerCase

class NavigationPage(BasePage):
    """导航栏页面"""

    # 导航栏重连
    __navigation_reconnectionBth = auto.GroupControl(SubName="access_reconnectionBtn")

    # 导航栏-标定
    __navigation_calibration = auto.GroupControl(SubName="access_Calibration")

    # 导航栏-选择模式
    __navigation_scan_mode = auto.GroupControl(SubName="access_Scan Mode")

    # 导航栏-扫描
    __navigation_scan = auto.GroupControl(SubName="access_Scan")

    # 导航栏-后处理
    __navigation_post_processing = auto.GroupControl(SubName="access_Post Processing")

    # 导航栏-测量
    __navigation_measurement = auto.GroupControl(SubName="access_Measurement Tools")

    # retry
    __retry_button = auto.GroupControl(SubName="access_Retry")


    def click_navigation_reconnection(self, max_wait_time=3):
        """导航栏重连"""
        loggerCase.info("导航栏重连")
        self.click(self.__navigation_reconnectionBth, max_wait_time=max_wait_time)
        self.loading()
        self.click_retry_button()
    
    def click_navigation_calibration(self, max_wait_time=3):
        """导航栏标定"""
        loggerCase.info("点击导航栏标定")
        self.click(self.__navigation_calibration, max_wait_time=max_wait_time)
    
    def click_navigation_scan_mode(self, max_wait_time=3):
        """导航栏选择扫描模式"""
        loggerCase.info("点击导航栏选择扫描模式")
        self.click(self.__navigation_scan_mode, max_wait_time=max_wait_time)
        if self.is_has_confirm_button():
            self.click_confirm_button()
        
    def click_navigation_scan(self, max_wait_time=3):
        """导航栏扫描界面"""
        loggerCase.info("点击导航栏扫描界面")
        self.click(self.__navigation_scan, max_wait_time=max_wait_time)
        
    def click_navigation_post_processing(self, max_wait_time=3):
        """导航栏后处理"""
        loggerCase.info("点击导航栏后处理")
        self.click(self.__navigation_post_processing, max_wait_time=max_wait_time)
        
    def click_navigation_measurement(self, max_wait_time=3):
        """导航栏测量"""
        loggerCase.info("点击导航栏测量")
        self.click(self.__navigation_measurement, max_wait_time=max_wait_time)

    def click_retry_button(self, max_wait_time=3):
        """重试"""
        if self.judge_element_exist(self.__retry_button,max_wait_time=3,is_end=False,is_need_screen=False,max_retries=1):
            loggerCase.info("点击重试")
            self.click(self.__retry_button, max_wait_time=max_wait_time)